/*
 * @Author: mengxiangji
 * @Email: 397082664@qq.com
 * @Date: 2020-07-07 15:41:23
 * @Last Modified by: mengxiangji
 * @Last Modified time: 2020-07-07 15:41:23
 * @Description: 获取小作业学生提交详情
 */

import 'dart:typed_data';

import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';

class ReqHomeworkStudentInfo {
  final Dio _dio;
  ReqHomeworkStudentInfo(this._dio);
  Future<Response> getHomeworkStudentInfo(
      {String studentHomeworkId, String classId}) {
    return _dio.get('/lesson/getHomeworkStudentInfo', queryParameters: {
      "studentHomeworkId": studentHomeworkId,
      "classId": classId
    });
  }

  //评价保存
  Future<Response> homeworkStudentEvaluateSave(
      {String studentHomeworkId,
      String evaluateResult,
      String evaluateInfo}) async {
    return _dio.post('/lesson/homeworkStudentEvaluate', queryParameters: {
      "studentHomeworkId": studentHomeworkId,
      "evaluateResult": evaluateResult,
      "evaluateInfo": evaluateInfo,
    });
  }

  //教师批阅
  Future<Response> homeworkStudentReviewSave({String studentHomeworkId}) async {
    return _dio.post('/lesson/homeworkStudentReview', queryParameters: {
      "studentHomeworkId": studentHomeworkId,
    });
  }

  //保存小作业批阅的图片
  Future<Response> homeworkMarkingPic(
      {@required String homeworkDetailId, ByteData picbytedata}) async {
    final buffer = picbytedata.buffer;
    return _dio.post('/lesson/homeworkMarkingPic',
        data: FormData.fromMap({
          "file": MultipartFile.fromBytes(
              buffer.asUint8List(
                  picbytedata.offsetInBytes, picbytedata.lengthInBytes),
              filename: "filename"),
          "homeworkDetailId": homeworkDetailId,
        }));
  }
}
